using System;
using System.Collections.Generic;

using Volo.Abp;
using Volo.Abp.Application.Services;

namespace Leo.Core.Application
{
    public abstract class BaseApplicationService : ApplicationService
    {
        protected Action<bool, string> CheckBussionErrors = (predicate, code) =>
        {
            if (predicate)
            {
                var exception = new BusinessException(code);

                throw exception;
            }
        };

        protected Action<bool, string, Dictionary<string, object>> CheckBussionErrorsWithData = (predicate, code, datas) =>
        {
            if (predicate)
            {
                var exception = new BusinessException(code);

                if (datas != null)
                {
                    foreach (var data in datas)
                        exception.WithData(data.Key, data.Value);
                }

                throw exception;
            }
        };
    }
}
